//
//  HMReputationDoctorCell.m
//  仿真开发
//
//  Created by B.HOPE on 2017/3/23.
//  Copyright © 2017年 B.HOPE. All rights reserved.
//

#import "HMReputationDoctorCell.h"
#import <Masonry.h>
#import <UIImageView+WebCache.h>

@interface HMReputationDoctorCell ()

/**
 申请
 */
@property (nonatomic, strong) UILabel *operation_count;

/**
 点赞数
 */
@property (nonatomic, strong) UILabel *banner;

/**
 花数量
 */
@property (nonatomic, strong) UILabel *flower;

/**
 名字
 */
@property (nonatomic, strong) UILabel *doctor_name;

/**
 头像
 */
@property (nonatomic, strong) UIImageView *doctor_portrait;

/**
 专业
 */
@property (nonatomic, strong) UILabel *doctor_title_name;

/**
 医院
 */
@property (nonatomic, strong) UILabel *doctor_hospital_name;

@property (nonatomic, strong) UIImageView *flowerView;

@property (nonatomic, strong) UIImageView *bannerView;

@property (nonatomic, strong) UIImageView *offsideView;

@end

@implementation HMReputationDoctorCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self setupUI];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self setupUI];
    }
    
    return self;
}

- (void)setupUI
{
    _doctor_portrait = [[UIImageView alloc] init];
    _doctor_portrait.image = [UIImage imageNamed:@"doctor_defaultphoto_male"];
    [self.contentView addSubview:_doctor_portrait];
    [_doctor_portrait mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.offset(10);
        make.size.mas_offset(CGSizeMake(50, 50));
    }];
    
    _doctor_name = [[UILabel alloc] init];
    _doctor_name.font = [UIFont systemFontOfSize:15];
    _doctor_name.text = @"老王";
    [self.contentView addSubview:_doctor_name];
    [_doctor_name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_doctor_portrait);
        make.left.equalTo(_doctor_portrait.mas_right).offset(10);
    }];
    
    _doctor_title_name = [[UILabel alloc] init];
    _doctor_title_name.font = [UIFont systemFontOfSize:15];
    _doctor_title_name.text = @"妇科";
    [self.contentView addSubview:_doctor_title_name];
    [_doctor_title_name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_doctor_name);
        make.left.equalTo(_doctor_name.mas_right).offset(10);
    }];

    _doctor_hospital_name = [[UILabel alloc] init];
    _doctor_hospital_name.font = [UIFont systemFontOfSize:15];
    _doctor_hospital_name.text = @"深圳妇产医院";
    [self.contentView addSubview:_doctor_hospital_name];
    [_doctor_hospital_name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_doctor_name.mas_bottom).offset(10);
        make.left.equalTo(_doctor_name);
    }];
    
    _operation_count = [[UILabel alloc] init];
    _operation_count.font = [UIFont systemFontOfSize:15];
    _operation_count.text = @"1";
    [self.contentView addSubview:_operation_count];
    [_operation_count mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_doctor_hospital_name.mas_bottom).offset(10);
        make.left.equalTo(_doctor_hospital_name).offset(15);
    }];

    _flowerView = [[UIImageView alloc] init];
    _flowerView.image = [UIImage imageNamed:@"xianhua"];
    [self.contentView addSubview:_flowerView];
    [_flowerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_operation_count);
        make.left.equalTo(_operation_count.mas_right).offset(50);
    }];

    _flower = [[UILabel alloc] init];
    _flower.font = [UIFont systemFontOfSize:15];
    _flower.text = @"1";
    [self.contentView addSubview:_flower];
    [_flower mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_flowerView);
        make.left.equalTo(_flowerView.mas_right).offset(5);
    }];

    _bannerView = [[UIImageView alloc] init];
    _bannerView.image = [UIImage imageNamed:@"jinqi"];
    [self.contentView addSubview:_bannerView];
    [_bannerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_flower);
        make.left.equalTo(_flower.mas_right).offset(50);
    }];

    _banner = [[UILabel alloc] init];
    _banner.font = [UIFont systemFontOfSize:15];
    _banner.text = @"1";
    [self.contentView addSubview:_banner];
    [_banner mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_bannerView);
        make.left.equalTo(_bannerView.mas_right).offset(5);
        make.bottom.offset(-10);
    }];
    
    _offsideView = [[UIImageView alloc] init];
    _offsideView.image = [UIImage imageNamed:@"position-right"];
    [self.contentView addSubview:_offsideView];
    [_offsideView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.right.offset(-20);
    }];
}

- (void)setModel:(HMReputationDoctoModel *)model
{
    _model = model;
    
    _operation_count.text = model.operation_count;
    _banner.text = model.banner;
    _flower.text = model.flower;
    _doctor_name.text = model.doctor_name;
    
//    NSString *name = [model.doctor_portrait stringByDeletingPathExtension];
    NSURL *url = [NSURL URLWithString:model.doctor_portrait];
    [_doctor_portrait sd_setImageWithURL:url];
    _doctor_title_name.text = model.doctor_title_name;
    _doctor_hospital_name.text = model.doctor_hospital_name;
    
}

@end
